﻿using DeviceMaintainGIS.BLL.Repair;
using DeviceMaintainGIS.Common;
using DeviceMaintainGIS.Model;
using DeviceMaintainGIS.Model.Repair;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Script.Serialization;

namespace DeviceMaintainGIS.Controllers
{

    /// <summary>
    /// 报修信息
    /// </summary>
    public class RepairHandleController : ApiController
    {
        /// <summary>
        /// 获取报修信息列表
        /// </summary>
        /// <returns></returns>
        public ReturnListVM<RepairResponse> Get([FromUri]RepairSelectRequest Request)
        {
            return new RepairService().GetRepairInfo(Request);
        }

        ///// <summary>
        ///// 通过报修编号查询报修信息
        ///// </summary>
        ///// <param name="RepairId"></param>
        ///// <returns></returns>
        //public ReturnVM<RepairResponse> Get(string RepairId)
        //{
        //    return new RepairService().GetRepairInfoByRepairId(RepairId);
        //}
        /// <summary>
        /// 添加报修工单
        /// </summary>
        /// <param name="request"></param>
        // POST: api/RepairHandle
        public ReturnMessageVM Post([FromBody]RepairRequest request)
        {
            JavaScriptSerializer jsonSerialize = new JavaScriptSerializer();
            String strJson = jsonSerialize.Serialize(request);//输出结果：{"Id":1,"UserName":"张三","Time":"\/Date(1297950721668)\/"}
            string pars = string.Format("报修工单提交或保存请求：\r\n 时间 = {0};\r\n 参数 = {1};"
            , System.DateTime.Now
            , strJson);
            LogHelper.WriteLog(typeof(FilterConfig), pars);
            return new RepairService().RepairAdd(request);
        }

    }
}
